package com.zj.dmsproxy.wrapper.condition;

import com.zj.dmsproxy.enums.QueryEnum;
import lombok.EqualsAndHashCode;
import lombok.Getter;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author arthur_zhou
 * @date 2023/11/3 10:58
 */
@EqualsAndHashCode(callSuper = true)
@Getter
public class BetweenCondition extends AbstractCondition {

    private final Object geValue;

    private final Object leValue;

    public BetweenCondition(String field, Object geValue, Object leValue) {
        super(false, field);
        this.geValue = geValue;
        this.leValue = leValue;
    }

    @Override
    public Map<String, Object> toCondition() {
        LinkedHashMap<String, Object> resultMap = new LinkedHashMap<>();
        resultMap.put(QueryEnum.GE.getRelation(), geValue);
        resultMap.put(QueryEnum.LE.getRelation(), leValue);
        return Collections.singletonMap(getField(), resultMap);
    }
}
